package com.tgh.utils;

import java.io.Serializable;

public class Vector4f implements Cloneable,Serializable{
    
    private static final long serialVersionUID = 4711587701773284822L;
    
    public Vector4f() {
    }

    public Vector4f(float initX, float initY, float initZ, float initW) {
        x = initX;
        y = initY;
        z = initZ;
        w = initW;
    }
    
    public Vector4f(float[] array,int offset) {
    	this.x=array[0+offset];
        this.y=array[1+offset];
        this.z=array[2+offset];
        this.w=array[3+offset];
	}
    
    public void copy(Vector4f vect4) {
        x=vect4.x;
        y=vect4.y;
        z=vect4.z;
        w=vect4.w;
    }
    
    public void copy(float x,float y,float z,float w) {
        this.x=x;
        this.y=y;
        this.z=z;
        this.w=w;
    }
    
    public void copy(float[] array,int offset) {
    	this.x=array[0+offset];
        this.y=array[1+offset];
        this.z=array[2+offset];
        this.w=array[3+offset];
	}
    
    @Override
    public Vector4f clone(){
    	Vector4f vector4f=null;
        try {
        	vector4f=(Vector4f) super.clone();
        } catch (CloneNotSupportedException e) {}
        return vector4f;
    }
    
    @Override
    public String toString() {
        return "("+x+","+y+","+z+","+w+")";
    }
    
    public float[] toArray() {
        return new float[]{x,y,z,w};
    }
    
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Float.floatToIntBits(w);
		result = prime * result + Float.floatToIntBits(x);
		result = prime * result + Float.floatToIntBits(y);
		result = prime * result + Float.floatToIntBits(z);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Vector4f other = (Vector4f) obj;
		if (Float.floatToIntBits(w) != Float.floatToIntBits(other.w))
			return false;
		if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
			return false;
		if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
			return false;
		if (Float.floatToIntBits(z) != Float.floatToIntBits(other.z))
			return false;
		return true;
	}


	public float x;
    public float y;
    public float z;
    public float w;
}
